package com.dehui.traders.ui.market.index;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import com.dehui.traders.BR;
import com.dehui.traders.R;
import com.dehui.traders.ui.market.broader.TheBroaderAdapter;
import com.dehui.traders.bean.TheBroaderBean;
import com.dehui.traders.databinding.FragmentTheIndexMarketBinding;
import com.dehui.traders.utils.SimulatedDataManager;
import com.dehui.traders.widgets.MyHScrollView;

import java.util.List;

import me.goldze.mvvmhabit.base.BaseFragment;

/**
 * Created by hqq on 18.4.2.
 */

public class TheIndexMarketFragment extends BaseFragment<FragmentTheIndexMarketBinding,TheIndexMarketViewModel>{

    public HorizontalScrollView mTouchView;
    private View view;

    @Override
    public int initContentView() {
        return R.layout.fragment_the_index_market;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public TheIndexMarketViewModel initViewModel() {
        return new TheIndexMarketViewModel(getContext());
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (view == null){
            view = super.onCreateView(inflater, container, savedInstanceState);
            initViews();
        }
        ViewGroup parent = (ViewGroup) view.getParent();
        if (parent != null)
            parent.removeView(view);
        return view;
    }

    private void initViews() {
//        binding.tabView.setFixes(new String[]{"指数全景","最新"})
//                .setOthers(new String[]{"涨幅","涨跌","换手","总手","总额","量比","震幅",
//                        "涨速","5日涨","5日换","样本量","样本均价","平均股本","总市值","占比%","静态市盈率"})
//                .setFragment(this)
//                .setAdapter(new TheBroaderAdapter(getContext(),mList,this)).build();
    }


    public void onScrollChanged(int l, int t, int oldl, int oldt) {
        List<MyHScrollView> mHScrollViews = binding.tabView.getScrollViews();
        for(MyHScrollView scrollView : mHScrollViews) {
            //防止重复滑动
            if(mTouchView != scrollView)
                scrollView.smoothScrollTo(l, t);
        }
    }

}
